package com.apache.ius.method;

import java.util.HashMap;
import java.util.Map;

import com.apache.cache.util.Validator;
import com.apache.ius.plugin.CustomMethodPlugin;

/**
 * 自定义类:查询不同品种拥有哪些过程。
 * @author admin
 */
@SuppressWarnings("serial")
public class SysCateProcessPluginImpl implements CustomMethodPlugin {

	@Override
	public Object beforeInvoke(Map<String, Object> param) {
		String cateId = Validator.getDefaultStr(String.valueOf(param.get("cateId")), null);
		String proType = Validator.getDefaultStr(String.valueOf(param.get("sysProcess.w_proType")), "0000000");
		StringBuffer dyncSql = new StringBuffer(
				"select  t1.process_id,t1.pro_name,t1.type_name,t1.pro_type,t2.info_id,t1.order_num from sys_process t1 ");
		dyncSql.append("left join (select t.process_id,t.info_id from sys_cate_process t where t.cate_id='" + cateId
				+ "' )t2 ");
		dyncSql.append("on t1.process_id=t2.process_id ");

		if (Validator.isNotNull(proType)) {
			dyncSql.append("where t1.pro_type ='" + proType + "' ");

		}
		dyncSql.append(" order by order_num ");
		Map<String, String> result = new HashMap<>(1);
		result.put(CustomMethodPlugin.pluginSql, dyncSql.toString());
		//param.put(CustomMethodPlugin.pluginSql, dyncSql.toString());
		return result;
	}

	@Override
	public Object doInvoke(Map<String, Object> param) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Object afterInvoke(Map<String, Object> param) {
		// TODO Auto-generated method stub
		return null;
	}

}
